package com.example.waibao.dao;


import com.example.waibao.entity.notice;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;

@Mapper
@Repository
public interface NoticeMapper {

//    @Insert("insert into notice(notice_type, message, notice_Initiator) values(#{notice_type}, #{message}, #{notice_Initiator})")
//    void setNotice(String notice_type, String message, String notice_Initiator);

    @Select("select * from notice")
    List<notice> getNotice();

//    @Select("select * from notice where day_time = #{day_time}")
//    List<notice> getNotice2(LocalDate day_time, int school_id);

//    @Insert("insert into sys_user_role(user_id,role_id) VALUES (#{user_id},#{role_id}) " +
//            "ON DUPLICATE KEY UPDATE role_id = #{role_id}")

    // ON DUPLICATE KEY UPDATE `type` = #{type},message = #{message},sys_id =#{sys_id}
    @Insert("insert into notice(message, sys_id,create_time,school_id,type) values(#{message}," +
            " #{sys_id}, #{create_time},#{school_id},#{type})")
    void setNotice2(String message, int sys_id, Date create_time, int school_id,int type);

    @Update("update faq set answer = #{answer}, sys_id=#{sys_id}, status = 1 where id = #{id}")
    void solve_question(int id, String answer, int sys_id);

    @Delete("delete from faq where id = #{id}")
    void delete_question(int id);

    @Update("update notice set status = 0 where id = #{id}")
    void delete_notice(int id);

    @Update("update notice set message = #{message}, sys_id = #{sys_id}, create_time = #{create_time}, type = #{type} where id = #{id}")
    void update_notice(int id, Date create_time, String message, Long sys_id, int type);
}
